<div class="form">

    <?php
    /**
     * @var $form CActiveForm
     * @var $model Training
     */
    $form = $this->beginWidget('CActiveForm', array(
        'id' => 'training-form',
        'enableAjaxValidation' => false,
    )); ?>


    <?php echo $form->errorSummary($model); ?>

    <div class="row">
        <?php echo $form->labelEx($model, 'name'); ?>
        <?php echo $form->textField($model, 'name', array('size' => 60, 'maxlength' => 255)); ?>
        <?php echo $form->error($model, 'name'); ?>
    </div>
    <div class="row">
        <?php echo $form->labelEx($model, 'image_id'); ?>
        <?php
        $this->widget('ext.EAjaxUpload.EAjaxUpload',
            array(
                'id' => 'uploadFile',
                'config' => array(
                    'action' => Yii::app()->createUrl('upload/image', array('ctype' => 'training')),
                    'allowedExtensions' => array("jpg", "png","jpeg","gif"), //array("jpg","jpeg","gif","exe","mov" and etc...
                    'sizeLimit' => 1 * 1024 * 1024, // maximum file size in bytes
                    'minSizeLimit' => 1024, // minimum file size in bytes
                    'onComplete' => "js:function(id, fileName, responseJSON){ $('#Training_image_id').val(responseJSON.item_id); }",
                )
            ));
        echo $form->hiddenField($model,'image_id');
        if($model->image_id){
            Yii::import('application.extensions.image.Image');
            $image = new Image(Yii::getPathOfAlias('webroot').'/'.$model->image->path);
            $image->resize(250, 100);
            $thumb = '/upload/images/thumb/'.substr_replace($model->image->path,'',0,14);
            $image->save(Yii::getPathOfAlias('webroot').$thumb);
            echo "<img src='".$thumb."' >";
        }
        ?>

    </div>
    <div class="row">
        <?php echo $form->labelEx($model, 'short_description'); ?>
        <?php
        //echo $form->textArea($model,'short_description',array('cols'=>70,'rows'=>15));
        $this->widget('application.extensions.ckeditor.CKEditor', array(
            'model' => $model,
            'attribute' => 'short_description',
            'language' => 'vi',
            'editorTemplate' => 'basic',
        ));
        ?>
        <?php echo $form->error($model, 'short_description'); ?>
    </div>

    <div class="row">
        <?php echo $form->labelEx($model, 'description'); ?>
        <?php
        //echo $form->textArea($model,'description',array('rows'=>6, 'cols'=>50));
        $this->widget('application.extensions.ckeditor.CKEditor', array(
            'model' => $model,
            'attribute' => 'description',
            'language' => 'vi',
            'editorTemplate' => 'full',
        ));
        ?>
        <?php echo $form->error($model, 'description'); ?>
    </div>
    <div class="row">
        <?php echo $form->labelEx($model, 'status'); ?>
        <?php echo $form->listBox($model, 'status', array(1 => 'Hoạt động', 2 => 'Không hoạt động'), array('size' => 1)); ?>
        <?php echo $form->error($model, 'status'); ?>
    </div>

    <div class="row buttons">
        <?php echo CHtml::submitButton($model->isNewRecord ? 'Tạo' : 'Lưu'); ?>
    </div>

    <?php $this->endWidget(); ?>

</div><!-- form -->